package com.example.shopping.controller;

import com.example.shopping.entity.Good;
import com.example.shopping.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xuan 2021/9/16
 */
@Controller
public class GoodsController {
   @Autowired
   GoodsService goodsService;

   @RequestMapping(value = "/fondGoodByName", method = {RequestMethod.POST})
   @ResponseBody
   public Good fondGoodByName(@RequestParam String name) {
      return goodsService.fondGoodByName(name);
   }

   @RequestMapping(value = "/insertGood", method = {RequestMethod.POST})
   @ResponseBody
   public String insertGood(@RequestParam Integer cid,@RequestParam Double price,@RequestParam String name){
      goodsService.insertGood(cid, price, name);
      return "success";
   }
}
